<?php
$breadcump = $this->params['pass'];
if ($this->params['action'] == 'browsebycompletedlist' AND $breadcump[0] == 'sold') {
    $this->Html->addCrumb('Completed Listings', '/products/browsebycompletedlist/sold', array('escape' => false));
    $this->Html->addCrumb('Sold Items', '/products/browsebycompletedlist/sold', array('escape' => false));
}
if ($this->params['action'] == 'browsebycompletedlist' AND $breadcump[0] == 'unsold') {
    $this->Html->addCrumb('Completed Listings', '/products/browsebycompletedlist/sold', array('escape' => false));
    $this->Html->addCrumb('Unsold Items', '/products/browsebycompletedlist/unsold', array('escape' => false));
}
if ($this->params['action'] == 'browsebycompletedlist' AND $breadcump[0] == 'all') {
    $this->Html->addCrumb('Completed Listings', '/products/browsebycompletedlist/sold', array('escape' => false));
    $this->Html->addCrumb('All Items', '/products/browsebycompletedlist/all', array('escape' => false));
}
?>
<?php //$this->Html->addCrumb('BROWSE & SEARCH');   ?>
<div class="products">
    <div class="search-title">BROWSE BY COMPLETE LISTING</div>
    <div class="rht-con">
        <div class="mdl-con widthstyle1" style=" width: 100%;">
            <div class="porduct-browse"  style=" width: 100%;">
                <?php $urlparam = $this->params['pass']; ?>
                <div class="search_result">
                    <div class="search_result">Showing results for<i style="color: #808080;">
                            <?php
                            if ($type == 'all') {
                                echo '" All Items "';
                            } elseif ($type == 'unsold') {
                                echo '" Unsold items "';
                            } elseif ($type == 'sold') {
                                echo '" Sold items "';
                            }
                            ?>
                        </i>
                    </div>
                    <?php
                    if (!empty($products)) {
                        echo count($products);
                    } else {
                        echo '0';
                    }
                    ?> results found.
                    <?php
                    if (!empty($products)) {
                        ?>
                        <div class="result">
                            <div class="container">
                                <?php if (empty($thumb)) { ?>
                                    <a href="<?php echo Configure::read('base_url') . 'products/browsebycompletedlist/' . $urlparam[0] . '/thumb?keywords='.$searchkey; ?>&query=<?php echo $query;?>'" class="switch_thumb1">Switch Thumb</a>
                                <?php } else { ?>
                                    <a href="<?php echo Configure::read('base_url') . 'products/browsebycompletedlist/' . $urlparam[0].'?keywords='.$searchkey; ?>&query=<?php echo $query;?>" class="switch_thumb1 swap">Switch Thumb</a>
                                <?php } ?>
                                <span style="float:right; line-height:26px;">Short by:
                                      <?php if (empty($thumb)) { ?>
                                    <select name="sortby" id="dynamic_select">
                                        <option value="<?php echo Configure::read('base_url') . 'products/browsebycompletedlist/' . $urlparam[0] . '/1?keywords='.$searchkey; ?>&query=<?php echo $query;?>'" <?php
                                        if (isset($urlparam[1]) AND $urlparam[1] == 1) {
                                            echo 'selected';
                                        }
                                        ?>>Time: Ending soonest</option>
                                        <option value="<?php echo Configure::read('base_url') . 'products/browsebycompletedlist/' . $urlparam[0] . '/2?keywords='.$searchkey; ?>&query=<?php echo $query;?>'" <?php
                                            if (isset($urlparam[1]) AND $urlparam[1] == 2) {
                                                echo 'selected';
                                            }
                                         ?>>Time: Newly Listed</option>
                                        <option value="<?php echo Configure::read('base_url') . 'products/browsebycompletedlist/' . $urlparam[0] . '/3?keywords='.$searchkey; ?>&query=<?php echo $query;?>'" <?php
                                        if (isset($urlparam[1]) AND $urlparam[1] == 3) {
                                            echo 'selected';
                                        }
                                        ?>>Price: Highest</option>
                                        <option value="<?php echo Configure::read('base_url') . 'products/browsebycompletedlist/' . $urlparam[0] . '/4?keywords='.$searchkey; ?>&query=<?php echo $query;?>'" <?php
                                        if (isset($urlparam[1]) AND $urlparam[1] == 4) {
                                            echo 'selected';
                                        }
                                        ?>>Price: Lowest</option>
                                    </select>
                                    <?php }else{?>
                                    <select name="sortby" id="dynamic_select">
                                        <option value="<?php echo Configure::read('base_url') . 'products/browsebycompletedlist/' . $urlparam[0] . '/thumb/1?keywords='.$searchkey; ?>&query=<?php echo $query;?>'" <?php
                                        if (isset($urlparam[2]) AND $urlparam[2] == 1) {
                                            echo 'selected';
                                        }
                                        ?>>Time: Ending soonest</option>
                                        <option value="<?php echo Configure::read('base_url') . 'products/browsebycompletedlist/' . $urlparam[0] . '/thumb/2?keywords='.$searchkey; ?>&query=<?php echo $query;?>'" <?php
                                            if (isset($urlparam[2]) AND $urlparam[2] == 2) {
                                                echo 'selected';
                                            }
                                         ?>>Time: Newly Listed</option>
                                        <option value="<?php echo Configure::read('base_url') . 'products/browsebycompletedlist/' . $urlparam[0] . '/thumb/3?keywords='.$searchkey; ?>&query=<?php echo $query;?>'" <?php
                                        if (isset($urlparam[2]) AND $urlparam[2] == 3) {
                                            echo 'selected';
                                        }
                                        ?>>Price: Highest</option>
                                        <option value="<?php echo Configure::read('base_url') . 'products/browsebycompletedlist/' . $urlparam[0] . '/thumb/4?keywords='.$searchkey; ?>&query=<?php echo $query;?>'" <?php
                                        if (isset($urlparam[2]) AND $urlparam[2] == 4) {
                                            echo 'selected';
                                        }
                                        ?>>Price: Lowest</option>
                                    </select>
                                    <?php }?>
                                </span>
                                <div id="Searchresult">
    <?php if (empty($thumb)) { ?>
                                        <div class="days_left"><span style="text-align:center; margin-left: 185px;"><b>Title</b></span><span style="text-align:right; margin-left: 565px;margin-right:50px;"><b>ID</b></span><b style="color:green;">Price</b><b style="margin-left:60px">Days Left</b></div>
                                        <ul class="display"></ul>
                                <?php } else { ?>	
                                        <ul class="display thumb_view"></ul>
                                <?php } ?>
                                </div>
                            </div>
                        </div>
                        <!-- Container element for all the Elements that are to be paginated -->
                        <div id="hiddenresult" style="display:none;">
                            <ul class="display">
                                <?php
                                if (!empty($products)) {
                                    $i = 0;
                                    foreach ($products as $product):
                                        $class = null;
                                        if ($i++ % 2 == 0) {
                                            $class = ' class="altrow"';
                                        }
                                        if (!empty($product['Product']['products_title'])) {
                                            ?>
                                            <li>
                                                <div class="content_block">
                                                    <div><a href="javascript:void(0);" alignLeft="1" controller="products" action="gallery_popup" ElmID="<?php echo $product['Product']['id']; ?>" onmouseover="showPop1(this)">
                                                    <?php
                                                    $image = "thumbs/";
                                                    echo $html->image($image . $thumbnail->render($product['Product']['products_thumbnailImage'], array('path' => 'thumbs', 'width' => 140, 'height' => 140, 'quality' => 80)
                                                            ), array('alt' => $product['Product']['products_title'])
                                                    );
                                                    ?>
                                                        </a>
                                                    </div>
                                                            <?php
                                                            if (empty($thumb))
                                                                echo"<h2>";else
                                                                echo"<h2 style='width:240px;'>";
                                                            ?><a href="<?php echo Configure::read('base_url'); ?>products/details/<?php echo $product['Product']['id']; ?>"><?php echo $product['Product']['products_title']; ?></a></h2>
                                                    <p><span style="width:95px;"><a href="<?php echo Configure::read('base_url'); ?>products/store/<?php echo $product['User']['id']; ?>"><?php echo $product['User']['username']; ?></a></span> <span style="color:green;"><?php echo 'US $' . $product['Product']['products_price']; ?></span>
                                                        <span><?php
                            if ($product[0]['totaldays'] > 0) {
                                echo $product[0]['totaldays'];
                            } else {
                                echo 0;
                            }
                            ?> days</span></p>
                                                </div>
                                            </li>
            <?php } endforeach; ?>
                                </ul>
                                    <?php
                                } else {
                                    echo 'No data Found!';
                                }
                                ?>
                        </div>
                        <div id="viewNumPageItem">
                            <span style="float:left; display:block;">Items per page:&nbsp;&nbsp;</span>
                            <ul class="newinline">
                                <li><a href="#25" >25</a></li>
                                <?php
                                if (count($products) >= 50) {
                                    ?>
                                    <li><a href="#50" >50</a></li>
                                    <?php
                                }
                                ?>
                                <?php
                                if (count($products) >= 100) {
                                    ?>
                                    <li><a href="#100" >100</a></li>
        <?php
    }
    if (count($products) >= 200) {
        ?>
                                    <li><a href="#200" >200</a></li>
        <?php
    }
    ?>
                            </ul>
                        </div>
                        <div class="clear"></div>
                        <div id="pagePositionNum"></div>
                        <div id="Pagination"></div>
                        <div id="gotoPage">
                            <input type="text" size="10" />
                            <button value="Go" >Go</button>
                        </div>
        <?php
    }
    ?>
                    <div class="clear"></div>
                </div>
            </div>
            <!--Start slider--><!--End Slider-->
        </div>              
        <div class="paging"> </div>
    </div>

<?php echo $this->element('home/browse_search_js'); ?>